package exam03printNum;

public class MyThread extends Thread{
    static int num;

    public MyThread(String name) {
        super.setName(name);
    }

    @Override
    public void run() {
        while (true){
            synchronized (MyThread.class){
                if (num >100){
                    break;
                }
                num ++;
                if (num % 2 == 0){
                    System.out.println(getName() + "打印" + num );
                }
            }
        }
    }
}
